﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace G.Service.Data
{
    public class PushInfoData : BaseData
    {
        public void AddPushInfo(string deviceId, string platform, string pushurl)
        {
            this.Entities.AddToPushInfoes(new PushInfo() { DeviceId = deviceId, Platform = platform, PushUrl = pushurl, UpdateDate = DateTime.Now });
        }

        public PushInfo GetPushInfoByDeviceId(string deviceId)
        {
            return this.GetALLPushInfos().FirstOrDefault(c => c.DeviceId == deviceId);
        }

        public void UpdatePushInfo(PushInfo push, string pushurl)
        {
            push.PushUrl = pushurl;
            push.UpdateDate = DateTime.Now;
        }

        public System.Data.Objects.ObjectQuery<PushInfo> GetALLPushInfos()
        {
            return this.Entities.PushInfoes;
        }
    }
}
